//
//  NSDate+Category.m
//  VET
//
//  Created by YZ on 2018/7/21.
//  Copyright © 2018年 YZ. All rights reserved.
//

#import "NSDate+Category.h"

@implementation NSDate (Category)

- (NSString *)localDateString
{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];//yyyy-MM-dd HH:mm
    //强制设为北京时区
    NSTimeZone* timeZone = [NSTimeZone timeZoneForSecondsFromGMT:8*3600];
    [dateFormatter setTimeZone:timeZone];
    NSString *dateStr = [dateFormatter stringFromDate:self];
    return dateStr;
}

- (NSString *)localDateStringWithFomaterTpye:(NSString *)type
{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:type];//yyyy-MM-dd HH:mm
    //强制设为北京时区
    NSTimeZone* timeZone = [NSTimeZone timeZoneForSecondsFromGMT:8*3600];
    [dateFormatter setTimeZone:timeZone];
    NSString *dateStr = [dateFormatter stringFromDate:self];
    return dateStr;
}

+ (NSString *)yz_countdownTimeStr:(NSTimeInterval)timeInterval{
    NSInteger minutes = timeInterval / 60;
    NSInteger seconds = (int)timeInterval % 60;
    NSString *secondStr = seconds >= 10 ? [NSString stringWithFormat:@"%ld",seconds]:[NSString stringWithFormat:@"0%ld",seconds];
    return [NSString stringWithFormat:@"00:0%ld:%@",(long)minutes,secondStr];
}
@end
